
	<table id="data"></table>

	<script type="text/javascript">
		
		(function($){

			setTimeout("data()",100); 
		})(jQuery);

		// 数据查询
		function data(){

			$('#data').datagrid({    
		    	url:'/daoBuilding/buildingJsonSeleft',
				method:'post',
				fit:true,
				fitColumns:true,
				striped:true,
				border:false,
				pagination:true,
				rownumbers:false,
				toolbar:'#query',
				singleSelect:true,
				pageSize:30,//每页显示的记录条数，默认为10 
		        pageList:[10,20,30,40,50,500,1000],//可以设置每页记录条数的列表 
			    columns:[[
			    	 {field:'id',title:'id',width:20,align:'center'},	    	 
			    	 {field:'cellName',title:'小区名称',width:40,align:'center'},
			    	 {field:'buildingNo',title:'栋号',width:40,align:'center'},
					 {field:'buildingName',title:'栋名称',width:40,align:'center',},
					 {field:'buildingFloor',title:'栋建筑楼层',width:40,align:'center'},
					 {field:'structure',title:'栋结构',width:40,align:'center'},
					 {field:'supportingFacilities',title:'栋配套设施',width:40,align:'center',
					 	formatter:function(value, row, index){
					 		var supportingFacilities = jQuery.parseJSON(row.supportingFacilities);

					 		var str;
							if(supportingFacilities.elevator){
								str = " 电梯 "
							} else {
								str = "";
							}
							if(supportingFacilities.parkingLot){
								str += " 停车场 "
							} else {
								str += "";
							}

							return str;

					 	}
					 },
					 {field:'createTime',title:'创建时间',width:40,align:'center'},
					 {field:'operation',title:'操作',width:20,align : 'center', 
						 formatter:function(value,row,index){
						 	var id= row.id; 
						 	var cellName= row.cellName;
						 	var buildingName= row.buildingName;
							var str = '<button class="btn btn-default btn-xs" style="margin:2px;" onClick="choice(\'' + id + '\',\''+ cellName + '\',\''+ buildingName + '\')" >选择</button>&nbsp;'
							return str;
						 }
					 }
			    ]],
				onLoadError:function(info){

				},
				onLoadSuccess:function(info){

					// setTimeout("doAdd()",10);
				},
				
			});  

			var p = $('#data').datagrid('getPager'); 
		    $(p).pagination({ 
		        beforePageText:'第',//页数文本框前显示的汉字 
		        afterPageText:'页 共 {pages} 页', 
		        displayMsg:'当前显示 {from} - {to} 条记录 共 {total} 条记录'
		    }); 
		} 

		// 选择
		function choice(id, cellName, buildingName){

			$.messager.confirm('确认','您确认想要执行吗？',function(r){    
				if(r){
			    	$.messager.progress({msg:'正在执行...',interval:3000,});

					$.messager.progress('close');
					// 执行父窗口方法
					window.parent.parentWindowClosed(id, cellName, buildingName);
				}
			});
		}

	</script>
